package com.ruoyi.travel.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.travel.domain.FoodDetail;
import com.ruoyi.travel.service.IFoodDetailService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 特色美食Controller
 * 
 * @author ruoyi
 * @date 2024-12-07
 */
@RestController
@RequestMapping("/travel/FoodDetail")
public class FoodDetailController extends BaseController
{
    @Autowired
    private IFoodDetailService foodDetailService;

    /**
     * 查询特色美食列表
     */
    @PreAuthorize("@ss.hasPermi('travel:FoodDetail:list')")
    @GetMapping("/list")
    public TableDataInfo list(FoodDetail foodDetail)
    {
        startPage();
        List<FoodDetail> list = foodDetailService.selectFoodDetailList(foodDetail);
        return getDataTable(list);
    }

    /**
     * 导出特色美食列表
     */
    @PreAuthorize("@ss.hasPermi('travel:FoodDetail:export')")
    @Log(title = "特色美食", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FoodDetail foodDetail)
    {
        List<FoodDetail> list = foodDetailService.selectFoodDetailList(foodDetail);
        ExcelUtil<FoodDetail> util = new ExcelUtil<FoodDetail>(FoodDetail.class);
        util.exportExcel(response, list, "特色美食数据");
    }

    /**
     * 获取特色美食详细信息
     */
    @PreAuthorize("@ss.hasPermi('travel:FoodDetail:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(foodDetailService.selectFoodDetailById(id));
    }

    /**
     * 新增特色美食
     */
    @PreAuthorize("@ss.hasPermi('travel:FoodDetail:add')")
    @Log(title = "特色美食", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FoodDetail foodDetail)
    {
        return toAjax(foodDetailService.insertFoodDetail(foodDetail));
    }

    /**
     * 修改特色美食
     */
    @PreAuthorize("@ss.hasPermi('travel:FoodDetail:edit')")
    @Log(title = "特色美食", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FoodDetail foodDetail)
    {
        return toAjax(foodDetailService.updateFoodDetail(foodDetail));
    }

    /**
     * 删除特色美食
     */
    @PreAuthorize("@ss.hasPermi('travel:FoodDetail:remove')")
    @Log(title = "特色美食", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(foodDetailService.deleteFoodDetailByIds(ids));
    }
}
